﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MediaGerbil
{
    public partial class HelpToolTip : UserControl
    {
        public Control TargetControl { get; set; }
        [Browsable(true)]
        public string ToolTipTitle { get; set; }

        public HelpToolTip()
        {
            InitializeComponent();
        }

        private void helpIcon_MouseEnter(object sender, EventArgs e)
        {
            toolTip.Hide(this);
            toolTip.ToolTipTitle = ToolTipTitle;
            string tooltipText = (TargetControl.Tag != null) ? TargetControl.Tag.ToString() : "Nothing to show!";
            int yOffset = tooltipText.Count(x => x == '\n') * 16;
            toolTip.Show(tooltipText, this, 0, -70 - yOffset);
        }

        private void helpIcon_MouseLeave(object sender, EventArgs e)
        {
            toolTip.Hide(TargetControl);
        }
    }
}
